package com.yukino.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerConfig {

    // 配置swagger的 docket的 bean实例
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                //.enable(false) 关闭使用swagger，发布时不使用
                .select()
                // RequestHandlerSelectors.any:扫描全部包
                // RequestHandlerSelectors.none:全不扫描
                .apis(RequestHandlerSelectors.basePackage("com.yukino.controller"))
                // 过滤路径
                .paths(PathSelectors.any())
                .build();
    }


    // 配置swagger 信息
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Swagger3接口文档")
                .description("API 描述")
                /*.contact(new Contact("", "", "")) //作者信息 name，url，email*/
                .version("1.0")
                .build();
    }
}

